/*     */ package com.qmsk.business.member.memberExcluService.controller;
/*     */ 
/*     */ import com.qmsk.business.member.memberExcluService.dao.memberExclusiveServiceDao;
/*     */ import com.qmsk.business.member.memberExcluServiceConsume.dao.memberExcluServiceConsumeDao;
/*     */ import com.qmsk.session.UserSessionInfo;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.io.IOException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/memberExclusiveService"})
/*     */ public class memberExclusiveService
/*     */ {
/*  39 */   private static final Logger logger = Logger.getLogger(memberExclusiveService.class);
/*     */ 
/*     */   @Autowired
/*     */   private memberExclusiveServiceDao dao;
/*     */ 
/*     */   @Autowired
/*     */   private memberExcluServiceConsumeDao memberExcluServiceConsumeDao;
/*     */ 
/*     */   @RequestMapping(value={"find/memberOwnServiceList/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListMemberCouponDetail(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  58 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*  59 */     Map params = new HashMap();
/*     */ 
/*  61 */     Long shopId = RequestUtils.getLong(request, "shopId");
/*  62 */     params.put("id", request.getParameter("id"));
/*  63 */     params.put("levelId", request.getParameter("levelId"));
/*  64 */     params.put("typeId", request.getParameter("typeId"));
/*  65 */     params.put("status", request.getParameter("status"));
/*  66 */     params.put("memberId", request.getParameter("memberId"));
/*  67 */     params.put("openId", request.getParameter("openId"));
/*  68 */     params.put("shopId", shopId);
/*     */     try
/*     */     {
/*  71 */       GsonEbRst gsonEbRst = this.dao.getInsurancePloicy(params, nPageIdx, 
/*  72 */         nPageSize);
/*  73 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/*  75 */       logger.error(e);
/*  76 */       ResponseUtils.setErrorMsgResponse(
/*  77 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"check"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertMember(HttpServletRequest request, HttpServletResponse response)
/*     */     throws IOException
/*     */   {
/*     */     try
/*     */     {
/*  87 */       Long id = RequestUtils.getLong(request, "id");
/*  88 */       Map params = new HashMap();
/*  89 */       params.put("id", id);
/*  90 */       GsonHeadOneRow g = this.dao.getGsonByParams(params);
/*  91 */       if (g == null) {
/*  92 */         ResponseUtils.setErrorMsgResponse("该服务不存在", response);
/*  93 */         return;
/*     */       }
/*     */ 
/*  96 */       Integer useNum = ObjectComm.objectToInteger(g.getValueOfName("useNums"));
/*  97 */       Integer nums = ObjectComm.objectToInteger(g.getValueOfName("nums"));
/*  98 */       Date UneffectDate = (Date)g.getValueOfName("UneffectDate");
/*     */ 
/* 100 */       if ((nums.intValue() != 0) && (useNum.intValue() >= nums.intValue())) {
/* 101 */         ResponseUtils.setErrorMsgResponse("服务次数已用完", response);
/* 102 */         return;
/*     */       }
/*     */ 
/* 105 */       Date now = new Date();
/* 106 */       if (now.after(UneffectDate)) {
/* 107 */         ResponseUtils.setErrorMsgResponse("该服务已失效", response);
/* 108 */         return;
/*     */       }
/*     */ 
/* 111 */       Long serviceId = ObjectComm.objectToLong(g.getValueOfName("serviceId"));
/* 112 */       Long shopId = ObjectComm.objectToLong(g.getValueOfName("shopId"));
/* 113 */       Long memberId = ObjectComm.objectToLong(g.getValueOfName("memberId"));
/* 114 */       String userName = UserSessionInfo.getUserNameOfRequest(request);
/* 115 */       String[] head = { "exId", "serviceId", "memberId", "createTime", "createMan", "shopId" };
/* 116 */       Object[] data = { id, serviceId, memberId, now, userName, shopId };
/* 117 */       int nresult = this.memberExcluServiceConsumeDao.insertGsonHeadOneRow(new GsonHeadOneRow(head, data));
/* 118 */       if (nresult > 0) {
/* 119 */         nresult = this.dao.updateUseNums(id);
/*     */       }
/*     */ 
/* 122 */       if (nresult > 0) {
/* 123 */         Long consumId = this.memberExcluServiceConsumeDao.getLastId();
/* 124 */         String[] h = { "consumeId" };
/* 125 */         Object[] date = { consumId };
/* 126 */         DbConnection.commit();
/* 127 */         ResponseUtils.toGsonEbRst(h, date, response);
/* 128 */         return;
/*     */       }
/* 130 */       DbConnection.rollback();
/*     */ 
/* 133 */       ResponseUtils.setSqlResultResponse(nresult, 
/* 134 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 135 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 138 */       DbConnection.rollback();
/* 139 */       logger.error(e);
/* 140 */       ResponseUtils.setErrorMsgResponse(
/* 141 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 142 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response) throws IOException
/*     */   {
/*     */     try
/*     */     {
/* 151 */       int nResult = 0;
/* 152 */       String sData = RequestUtils.getStringOfData(request);
/*     */ 
/* 154 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 155 */       if ((p != null) && (p.isExistsUpdateRows())) {
/* 156 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/*     */ 
/* 159 */       if (nResult > 0) {
/* 160 */         DbConnection.commit();
/* 161 */         ResponseUtils.setSuccessResponse(response);
/*     */ 
/* 163 */         return; }
/* 164 */       DbConnection.rollback();
/* 165 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 166 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 167 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 170 */       DbConnection.rollback();
/* 171 */       logger.error(e);
/* 172 */       ResponseUtils.setErrorMsgResponse(
/* 173 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 174 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void del(HttpServletRequest request, HttpServletResponse response) throws IOException
/*     */   {
/*     */     try {
/* 182 */       String id = RequestUtils.getStringOfId(request);
/* 183 */       String[] ids = id.split(",");
/* 184 */       int nResult = this.dao.deleteParams(ids);
/* 185 */       if (nResult > 0) {
/* 186 */         DbConnection.commit();
/* 187 */         ResponseUtils.setSuccessResponse(response);
/*     */ 
/* 189 */         return; }
/* 190 */       DbConnection.rollback();
/* 191 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 192 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 193 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 196 */       DbConnection.rollback();
/* 197 */       logger.error(e);
/* 198 */       ResponseUtils.setErrorMsgResponse(
/* 199 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 200 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.memberExcluService.controller.memberExclusiveService
 * JD-Core Version:    0.5.3
 */